<?php
/**
 * 知也控制器
 */
class Detail extends BaseAction
{
	/**
	 * 初始化
	 */
	public function _init()
	{

	}

	/**
	 * 默认动作
	 */
	protected function _default()
	{
		#知也详情开始

		#获取到参数
		$id = $this->getParam('id');
		#组合查询语句
		$where = '';
		$where.='id = '.$id;
		$strCheckState = '  and  checkState =2';
#查询条件
		$strWhere = $where.$strCheckState;


		#获取数据信息
		$list = new publicGetDataModel();
		$listData = $list->getData($where = $strWhere,$limit = 1,$fields = 'id,title,hot,img,content,checkState,dateline',$order = 'dateline',$table='knows');

		if($listData){
			$listData = $listData[0];
		}else{
			$this->goTo404('该信息不存在!');
		}

		#知也详情结束

#获取上一篇
		$frontsql=' SELECT id,title FROM knows WHERE dateline< '.$listData['DATELINE'].' and checkState !=1 ORDER BY dateline DESC LIMIT 1';
		$front=DB::select($frontsql);
//		print_r($front);

#获取下一篇
		$behindsql=' SELECT id,title FROM knows WHERE dateline>'.$listData['DATELINE'].' and checkState !=1 ORDER BY dateline ASC LIMIT 1';
		$behind=DB::select($behindsql);
//		print_r($behind);


		#热门知也开始
#组合查询语句
		$where = '';
		$strCheckState = '   checkState !=1 and id not in('.$id.')';
#查询条件
		$strWhere = $where.$strCheckState;


		#获取数据信息
		$list = new publicGetDataModel();
		$hotData = $list->getData($where = $strWhere,$limit = 10,$fields = 'id,title,hot,img,content,checkState,dateline',$order = 'dateline',$table='knows');
//DB::echoExeSql();

//print_r($hotData);

		#热门知也结束



		$this->assign('listData',$listData);
		$this->assign('hotData',$hotData);
		$this->assign('behind',$behind);
		$this->assign('front',$front);
//		print_r($listData);

		$this->tpl_full_path('/front/knows/newsDetail');
	}




}
?>
